package pro.shushi.pamirs.hr.api.model.auth;

import com.alibaba.fastjson.annotation.JSONField;
import pro.shushi.pamirs.boot.base.ux.annotation.field.UxWidget;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTableSearch;
import pro.shushi.pamirs.hr.api.pmodel.AuthResourceMenu;
import pro.shushi.pamirs.hr.api.pmodel.AuthResourceModule;
import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.base.IdModel;

@Model.model(AppAuthResource.MODEL_MODEL)
@Model(displayName = "权限资源", summary = "权限资源")
@Model.Advanced(index = {"menuId"}, unique = {"resUnique"})
public class AppAuthResource extends IdModel {

    public static final String MODEL_MODEL = "hr.auth.AppAuthResource";

    @JSONField(serialize = false)
    @Field.many2one
    @Field(displayName = "模块", required = true)
    @Field.Relation(relationFields = {"module"}, referenceFields = {"module"})
    private AuthResourceModule moduleDef;

    @Field.String
    @Field(displayName = "模块编码", invisible = true)
    private String module;

    @JSONField(serialize = false)
    @Field.many2one
    @Field(displayName = "菜单", required = true)
    @Field.Relation(relationFields = {"menuId"}, referenceFields = {"id"}, domain = "module==${activeRecord.moduleDef.module}")
    private AuthResourceMenu menuDef;

    @Field.Integer
    @Field(displayName = "菜单ID", invisible = true)
    private Long menuId;

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field.String
    @Field(displayName = "资源编码", required = true)
    private String resCode;

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field.String
    @Field(displayName = "资源唯一标识", required = true)
    private String resUnique;

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field.String
    @Field(displayName = "资源显示名称", required = true)
    private String displayName;

    @Field.String
    @Field(displayName = "请求URI")
    private String path;

    @Field.Text
    @Field(displayName = "描述说明")
    private String desc;

    @Field.Integer
    @Field(displayName = "资源关联ID",invisible = true)
    private Long resourceId;

}
